﻿using System.IO;
using System.Threading.Tasks;

namespace housingsafety.server.Svcs
{
    /// <summary>
    /// 文件缓存存储
    /// </summary>
    public interface IImageCacheProvider
    {
        /// <summary>
        /// 提供程序名称
        /// </summary>
        string ProviderName { get; }

        /// <summary>
        /// 文件是否存在
        /// </summary>
        /// <param name="fileId">文件ID</param>
        /// <returns></returns>
        bool ExistFile(string fileId);

        /// <summary>
        /// 获取对象流
        /// </summary>
        /// <param name="fileId">文件ID</param>
        /// <returns>对象流</returns>
        Task<Stream> GetCacheStreamAsync(string fileId);

        /// <summary>
        /// 获取对象流
        /// </summary>
        /// <param name="fileId">文件ID</param>
        /// <param name="contentType">MIME</param>
        /// <param name="oriImg">原始流</param>
        /// <returns>对象流</returns>
        Task<Stream> BuildCacheStreamAsync(string fileId, string contentType, Task<Stream> oriImg);

        /// <summary>
        /// 创建缓存
        /// </summary>
        /// <param name="fileId">文件ID</param>
        /// <param name="contentType">MIME</param>
        /// <param name="objectStream"></param>
        /// <returns></returns>
        Task Cache(string fileId, string contentType, Stream objectStream);
    }
}
